#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int time_elapse(int hour, int minute, int second)
{
    return hour * 3600 + minute * 60 + second;
}

int main()
{
    int nCase;
    for (scanf("%d", &nCase); nCase > 0; nCase--)
    {
        int h, m, s;
        int t1, t2;
        scanf("%d:%d:%d", &h, &m, &s);
        t1 = time_elapse(h, m, s);
        scanf("%d:%d:%d", &h, &m, &s);
        t2 = time_elapse(h, m, s);
        printf("%d %d %d\n", t1, t2, abs(t1 - t2));
    }
    return 0;
}
